home *** CD-ROM | disk | FTP | other *** search
- Path: kalabsha.trin.cam.ac.uk!93bb
- From: 93bb@eng.cam.ac.uk (Ben Blaukopf)
- Newsgroups: comp.lang.c++
- Subject: Re: easy c++ question
- Date: Sat, 13 Apr 1996 15:38:56
- Organization: University of Cambridge, England
- Message-ID: <93bb.38.000FA695@eng.cam.ac.uk>
- References: <316901DA.3138C677@ablecom.net> <66W25t5UoNB@jth.ping.de> <Pine.OSF.3.91.960411092945.20958C-100000@bud.cc.swin.edu.au>
- NNTP-Posting-Host: kalabsha.trin.cam.ac.uk
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]
-
- In article <Pine.OSF.3.91.960411092945.20958C-100000@bud.cc.swin.edu.au> John Joseph Newbigin <079519@bud.cc.swin.edu.au> writes:
- >Subject: Re: easy c++ question
- >From: John Joseph Newbigin <079519@bud.cc.swin.edu.au>
- >Date: Thu, 11 Apr 1996 09:33:04 +1000
-
- >On 9 Apr 1996, Jens Theisen wrote:
-
- >> You should be right. Constructors are called implicitly when an object of
- >> this class is created. Perhaps your constructor hasn't the same parameter
- >> list than the one your are using to create the object.
- >>
- >....Sometimes...
- >if you have a class myclass with a constructor and you do
-
- >myclass *a;
- >a=new myclass[5];
-
- >the constructor is not called for every member (a[0], a[1]..)
- >Does this help?
- > Newbs
- The ctor certainly is called for every member. Furthermore, when you
- delete the array
- delete[] a;
- the dtor is also called for every member.
-
- a = new myclass[5]
-
- allocates a block of memory big enough for 5 objects, and constructs them.
-
- Ben Blaukopf
-